package com.woniuxy.ssm.powermag.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.woniuxy.ssm.entity.DeptEntity;
import com.woniuxy.ssm.powermag.mapper.DeptMapper;
import com.woniuxy.ssm.powermag.service.IDeptService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Transactional(readOnly = true)
@Service
public class DeptServiceImpl implements IDeptService {

    @Resource
    private DeptMapper deptMapper;

    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public void save(DeptEntity deptEntity) {
        deptMapper.save(deptEntity);
    }

    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public void update(DeptEntity deptEntity) {
        deptMapper.update(deptEntity);
    }

    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public void deleteById(Long id) {
        deptMapper.deleteById(id);
    }

    @Override
    public DeptEntity getById(Long aLong) {
        return deptMapper.getById(aLong);
    }

    @Override
    public Page<DeptEntity> page(Integer page, Integer rows, DeptEntity deptEntity) {
        PageHelper.startPage(page,rows);
        return (Page<DeptEntity>) deptMapper.page(deptEntity);
    }
}
